package forward.Module.Modules.Misc;

import forward.Module.Module;
import forward.Module.ModuleType;
import forward.Module.Modules.Move.NoSlow;
import forward.api.EventHandler;
import forward.api.Events.World.EventPacketReceive;
import forward.api.Events.World.EventPacketSend;
import forward.api.Value.Mode;
import net.minecraft.network.Packet;
import net.minecraft.network.play.client.C00PacketKeepAlive;
import org.apache.commons.lang3.RandomUtils;

public class Disabler extends Module{
    private int width;
    public static Mode<Enum> mode = new Mode("Mode", "Mode", (Enum[])DisablerMode.values(), (Enum) DisablerMode.MinePlexCombat);
    public Disabler() {
        super("Disabler", new String[] {"Disabler"}, ModuleType.Misc);
        this.addValues(mode);
    }
    @EventHandler
    public void onPacketSend(EventPacketSend event){
        Packet packet=event.getPacket();
        if (mode.getValue()==DisablerMode.MinePlexCombat){
            if (packet instanceof C00PacketKeepAlive) {
                event.setCancelled(true);
                mc.getNetHandler().addToSendQueue(new C00PacketKeepAlive(((C00PacketKeepAlive) packet).getKey() - RandomUtils.nextInt(1000, 2147483647)));
               // debugMessage("Packet C00");
            }
        }
    }
    @EventHandler
    public void onPacketReceive(EventPacketReceive event){
        Packet packet=event.getPacket();
        if (mode.getValue()==DisablerMode.MinePlexCombat){
            if (packet instanceof C00PacketKeepAlive) {
                event.setCancelled(true);
                mc.getNetHandler().addToSendQueue(new C00PacketKeepAlive(((C00PacketKeepAlive) packet).getKey() - RandomUtils.nextInt(1000, 2147483647)));
               // debugMessage("Packet C00");
            }
        }
    }
    enum DisablerMode{
        MinePlexCombat;
    }

}
